﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     Keyword业务接口的实现
    /// 作者：     lwl
    /// 日期：     2011/10/14
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class KeywordSqlMapDao : BaseSqlMapDao, IKeywordDao
    {
        private static KeywordSqlMapDao instance = null;
        private static object syncRoot = new object();

        private KeywordSqlMapDao()
        {
            //
            // TODO: 此处添加KeywordSqlMapDao的构造函数
            //
        }
        public static IKeywordDao Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new KeywordSqlMapDao();
                        }
                    }
                }
                return instance;
            }
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectKeywordByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<Keyword> GetList()
        {
            try
            {
                return ExecuteQueryForList<Keyword>("SelectKeyword", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<Keyword> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<Keyword>("SelectKeywordByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="KeyID"></param>
        /// <returns></returns>
        public Keyword GetDetail(Keyword keyword)
        {
            try
            {
                return ExecuteQueryForObject<Keyword>("SelectKeyword", keyword) as Keyword;
            }
            catch
            {
                throw;
            }
        }
        
        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="keyword"></param>
        /// <returns></returns>
        public object Add(Keyword keyword)
        {
            //int id = GetId("Keyword");
            //keyword.KeyID = id;

            try
            {
                return ExecuteInsert("InsertKeyword", keyword);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="keyword"></param>
        /// <returns></returns>
        public int Update(Keyword keyword)
        {
            try
            {
                return ExecuteUpdate("UpdateKeyword", keyword);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="KeyID"></param>
        /// <returns></returns>
        public int Delete(System.String keyid)
        {
            try
            {
                return ExecuteDelete("DeleteKeyword", keyid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="keyword"></param>
        /// <returns></returns>
        public int Delete(Keyword keyword)
        {
            try
            {
                return ExecuteDelete("DeleteKeyword", keyword.KeyID);
            } 
            catch
            {
                throw;
            }
        }

        public IList<string> GetHotKey(Hashtable ht)
        {
            try
            {
                return ExecuteQueryForList<string>("GetHotKey", ht);
            }
            catch 
            {
                
                throw;
            }
        }


    }
}
